package cn.zhiwen;

import cn.zhiwen.exception.GlobalErrorAttributes;
import cn.zhiwen.filter.AccessFilter;
import cn.zhiwen.filter.ErrorExtFilter;
import cn.zhiwen.filter.ErrorFilter;
import cn.zhiwen.filter.ErrorFilterProcessor;
import com.netflix.zuul.FilterProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableZuulProxy
public class ZuulApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZuulApplication.class,args);
        //这个是让自定义的
        FilterProcessor.setProcessor(new ErrorFilterProcessor());
    }

    @Bean
    public AccessFilter accessFilter(){
        return new AccessFilter();
    }

    @Bean
    public ErrorExtFilter errorExtFilter(){
        return new ErrorExtFilter();
    }

    @Bean
    public ErrorFilter errorFilter(){
        return new ErrorFilter();
    }

    @Bean
    public GlobalErrorAttributes globalErrorAttributes(){
        return new GlobalErrorAttributes();
    }
}
